package com.applet.api.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Create Time: 2019年11月11日 23:06
 *
 * @author lxl
 * @Dec
 **/
@Configuration
@EnableSwagger2
@Profile("dev")
public class Swagger2Config {
    @Value("${swagger.show}")
    private boolean swaggerShow = true;
    @Bean
    public Docket api() {


        return new Docket(DocumentationType.SWAGGER_2).enable(swaggerShow)
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false);
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("applet -api接口")
                .description("applet-api接口说明文档")
                .termsOfServiceUrl("")
                .version("0.1")
                .build();
    }
}
